package flicker;


import com.aetrion.flickr.Flickr;
import com.aetrion.flickr.REST;
import com.aetrion.flickr.photos.SearchParameters;
import com.aetrion.flickr.photos.PhotoList;
import com.aetrion.flickr.photos.PhotosInterface;
import com.aetrion.flickr.photos.Photo;

public class FlickrImageFinder {

    private String my_key="e700db8c46d0b2f013c306df4ebacbb2";
    private String svr_flickr="www.flickr.com";


        public static void main(String[] args) throws Exception{
                FlickrImageFinder finder = new FlickrImageFinder();
                finder.getImages("Bogota Colombia");
        }

        public String getImages(String tags) throws Exception {


            String key=this.my_key;
            String svr=this.svr_flickr;
            REST rest=new REST();
            rest.setHost(svr);

            Flickr flickr=new Flickr(key, rest);
            Flickr.debugStream=false;

            SearchParameters searchParams=new SearchParameters();
            searchParams.setSort(SearchParameters.INTERESTINGNESS_DESC);

            String[] tag=tags.split(" ");
            searchParams.setTags(tag);

            //Initialize PhotosInterface object
            PhotosInterface photosInterface=flickr.getPhotosInterface();
            //Execute search with entered tags
            PhotoList photoList=photosInterface.search(searchParams,200,0);

            String images ="";

            if(photoList!=null){
               for(int i=0;i<photoList.size();i++){
                  Photo photo=(Photo)photoList.get(i);
                  images+=photo.getLargeUrl()+" ";
               }
            }
            return images;
        }
}